<form class="form-horizontal" id="winModal">
    <input id="id" name="id" type="hidden">
    <input id="userName" name="userName" type="hidden">
    <div class="form-group">
        <label class="col-sm-3 control-label text-left">账号密码：</label>
        <div class="col-sm-8">
            <input id="password" name="password" class="form-control" type="password" placeholder="请输入账号密码">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label text-left">确认密码：</label>
        <div class="col-sm-8">
            <input id="confirm_password" name="confirm_password" class="form-control" type="password"
                   placeholder="请再次输入确认密码">
        </div>
    </div>


</form>
<script type="text/javascript">
    $(function () {
        var e = "<i class='fa fa-times-circle'></i> ";
        $("#winModal").validate({
            rules: {           //定义验证规则,其中属性名为表单的name属性
                password: {
                    required: true,
                    minlength: 6,
                    stringPassWord: true,
                },
                confirm_password: {
                    required: true,
                    equalTo: "#password"
                },

            },
            messages: {       //自定义验证消息

                password: {
                    required: e + "请再次输入密码",
                    stringPassWord: e + "只能包括英文、数字和下划线，下划线不能开头",
                    rangelength: $.validator.format(e + "密码位数最低为{0}个字符。")
                },
                confirm_password: {
                    required: e + "请输入确认密码",
                    equalTo: e + "密码验证需要与密码一致"
                },

            },
        });

    });
</script>